package com.example.demo.model.goods.goods.controler;


import com.example.demo.Results.ResultClass;
import com.example.demo.model.goods.goods.entity.ShopGoods;
import com.example.demo.model.goods.goods.entity.ShopGoodsType;
import com.example.demo.model.goods.goods.service.ShopGoodsService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author STAHYW
 * @since 2021-10-02
 */
@RestController
@RequestMapping("/goods/shopGoods")
public class ShopGoodsResource {

    @Autowired
    private ShopGoodsService shopGoodsService;



    @ApiOperation(value = "商品分类列表", notes = "商品分类列表")
    @GetMapping("/goodsList")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNo", value = "页码", dataType = "Integer", example = "1"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "Integer", example = "10"),
            @ApiImplicitParam(name = "shopGoods", value = "商品名称", dataType = "String", example = "锅包肉")
    })
    public ModelAndView goodsList(Integer pageNo, Integer pageSize,String shopGoods){

        return shopGoodsService.goodsList(pageNo,pageSize,shopGoods);
    }

    @PostMapping("/goodsDel")
    @ApiOperation(value = "商品列表", notes = "商品删除")
    @ApiImplicitParam(name = "id", value = "主健", dataType = "Integer", example = "1")
    public ResultClass goodsDel(Integer id) {

         return shopGoodsService.goodsDel(id);


    }

    @GetMapping("/goodsEdit")
    @ApiOperation(value = "显示商品类型修改页", notes = "显示商品类型修改页")
    @ApiImplicitParam(name = "id", value = "主键", dataType = "Integer", example = "1")
    public ModelAndView goodsTypeEdit(Integer id) {
        return shopGoodsService.goodsTypeEdit(id);
    }


    @PostMapping("/goodsEditDo")
    @ApiOperation(value = "菜品添加或修改操作", notes = "菜品添加或修改操作")
    public ResultClass goodsTypeEditDo(ShopGoods shopGoods, MultipartFile file) {
        return shopGoodsService.goodsTypeEditDo(shopGoods,file);
    }

}

